package com.zx.controller;

import com.zx.entity.Order;
import com.zx.service.OrderService;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

/**
 * @author jackwu
 * @version 1.0
 * @date 2020-03-08
 */
@RestController
@RequestMapping("/order")
public class OrderController {

    @Resource
    private OrderService orderService;

    /**
     * 创建订单
     * @param pid 商品id
     * @return 订单
     */
    @GetMapping("/order/{pid}")
    @ResponseStatus(HttpStatus.CREATED)
    public Order addOrder(@PathVariable("pid") Integer pid) {
        return orderService.addOrder(pid);
    }

}
